package com.cqhfan.chatroom.controller;


import com.cqhfan.chatroom.domain.dto.CreateChatGroupDTO;
import com.cqhfan.chatroom.domain.po.ChatGroup;
import com.cqhfan.chatroom.domain.vo.ChatGroupInfoVO;
import com.cqhfan.chatroom.domain.vo.ChatGroupVO;
import com.cqhfan.chatroom.service.IChatGroupService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 群表 前端控制器
 * </p>
 *
 * @author 眭传洪
 * @since 2024-11-20
 */
@Tag(name = "群组相关接口")
@RestController
@RequestMapping("/chatGroup")
@RequiredArgsConstructor
public class ChatGroupController {

    private final IChatGroupService chatGroupService;

    @Operation(summary = "创建群聊")
    @PostMapping("/createChatGroupInfo")
    public Long createChatGroupInfo(@RequestBody CreateChatGroupDTO body) {
        return chatGroupService.createChatGroupInfo(body);
    }

    @Operation(summary = "获取群聊信息")
    @GetMapping("/getChatGroupInfo/{groupId}")
    public ChatGroupInfoVO getChatGroupInfo(@PathVariable("groupId") Long groupId) {
        return chatGroupService.getChatGroupInfo(groupId);
    }

    @Operation(summary = "获取我的群聊信息")
    @GetMapping("/listMyChatGroup")
    public List<ChatGroupVO> listMyChatGroup() {
        return chatGroupService.listMyChatGroup();
    }

}
